Міністерство освіти та науки України
Національний університет “Львівська політехніка”
Інститут комп’ютерних наук та інформаційних технологій
Кафедра автоматизованих систем управління
Лабораторна робота №1
з дисципліни “ Комп`ютерна графіка ”
Тема: «Робота в декартовій
системі координат»
Програмна реалізація:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
Button1: TButton;
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
LabeledEdit3: TLabeledEdit;
LabeledEdit4: TLabeledEdit;
LabeledEdit5: TLabeledEdit;
LabeledEdit6: TLabeledEdit;
Button2: TButton;
LabeledEdit7: TLabeledEdit;
LabeledEdit8: TLabeledEdit;
Button3: TButton;
LabeledEdit9: TLabeledEdit;
LabeledEdit10: TLabeledEdit;
LabeledEdit11: TLabeledEdit;
LabeledEdit12: TLabeledEdit;
Button4: TButton;
LabeledEdit13: TLabeledEdit;
LabeledEdit14: TLabeledEdit;
LabeledEdit15: TLabeledEdit;
LabeledEdit16: TLabeledEdit;
LabeledEdit17: TLabeledEdit;
LabeledEdit18: TLabeledEdit;
Button5: TButton;
LabeledEdit19: TLabeledEdit;
LabeledEdit20: TLabeledEdit;
LabeledEdit21: TLabeledEdit;
LabeledEdit22: TLabeledEdit;
Button6: TButton;
LabeledEdit23: TLabeledEdit;
LabeledEdit24: TLabeledEdit;
LabeledEdit25: TLabeledEdit;
LabeledEdit26: TLabeledEdit;
function y(a:integer):integer;
procedure draw_axises();
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
xc,yc:integer;
llength,wwidth:integer;
implementation
{$R *.dfm}
function TForm1.y(a:integer):integer;
begin
y:=((PaintBox1.Height div 2)-a);
end;
procedure TForm1.draw_axises();
var
x,y,i:integer;
//xc,yc:integer;
//length,width:integer;
begin
xc:=PaintBox1.Width div 2;
yc:=PaintBox1.Height div 2;
llength:=PaintBox1.Height div 40;
wwidth:=6;
with PaintBox1.Canvas do
begin
//Ellipse(1,1,44,66);
PaintBox1.Refresh;
Pen.Color:=clBlack;
MoveTo(0,yc);
LineTo(PaintBox1.Width,yc);
MoveTo(xc,0);
LineTo(xc,(PaintBox1.Width));
//MoveTo(0,yc);
//LineTo(45,34);
x:=xc;
while (x>0) do
begin
MoveTo(x,yc-wwidth);
LineTo(x,yc+wwidth);
x:=x-llength;
end;
x:=xc;
while (x<PaintBox1.Width) do
begin
MoveTo(x,yc-wwidth);
LineTo(x,yc+wwidth);
x:=x+llength;
end;
y:=yc;
while (y>0) do
begin
MoveTo(xc-wwidth,y);
LineTo(xc+wwidth,y);
y:=y-llength;
end;
y:=yc;
while (y<PaintBox1.Height) do
begin
MoveTo(xc-wwidth,y);
LineTo(xc+wwidth,y);
y:=y+llength;
end;
TextOut(round(PaintBox1.Width*0.98),round(yc*1.1),'X');
TextOut(round(xc*1.05),round(PaintBox1.Height*0.02),'Y');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
xp,yp:integer;
point_size:integer;
// a,b,c,d:double;
begin
draw_axises();
point_size:=2;
xp:=strtoint(LabeledEdit1.Text);
yp:=strtoint(LabeledEdit2.Text);
with PaintBox1.Canvas do
begin
Pen.Color:=clRed;
//Pen.Width:=Pen.Width*2;
Ellipse(xp*llength+xc-point_size,yc-yp*llength-point_size,
xc+xp*llength+point_size,yc-yp*llength+point_size);
...